<template>
	<view class="mainpadding2">
		<u-navbar title="區域管理" placeholder autoBack>
			<view class="flexright xiaohui" slot="right" @click="jumpurl('/pages/workbench/tianjiaqy')">添加</view>
		</u-navbar>
		<view class="flexcenter" v-if="!list.length">
			<view class="placeholderimage" style="margin-top: 100rpx;"></view>
		</view>
		<view class="mainpadding_top ffffff radius" v-for="item in list" :key="item.id">
			<div class="flexbetween">
				<view class="titletext xiaohuang bold">{{item.name}}</view>
				<view class="xiaohei ershil">排序：{{item.weigh}}</view>
			</div>
			<view class="flexright margin_top">
				<view class="flexleft margin_left" @click.stop="jumpdetail('/pages/workbench/tianjiaqy?id=',item.id)">
					<u-icon name="edit-pen" color="#999" size="16"></u-icon>
					<view class="xiaohei">編輯</view>
				</view>
				<view class="flexleft margin_left" @click.stop="delitem(item.id)">
					<u-icon name="trash" color="#999" size="16"></u-icon>
					<view class="xiaohei">刪除</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
			}
		},
		onShow() {
			this.getqyList()
		},
		methods: {
			getqyList() {
				this.http.request("/api/shop/shopAreaIndex", 'GET', {
					shop_id: uni.getStorageSync("shop_id")
				}).then(res => {
					this.list = res.data
				})
			},
			delitem(id) {
				this.http.modal('提示', '確認刪除當前數據嗎？', true, (res) => {
					if (res) {
						this.http.request("/api/shop/delShopArea", 'GET', {
							id
						}).then(res => {
							if (res.code == 1) {
								this.http.toast("刪除成功")
								this.getqyList()
							} else {
								this.http.toast(res.msg);
							}
						})

					}
				})
			},
		}
	}
</script>

<style>

</style>